package com.wanxi.demo;

import javafx.scene.transform.Scale;

import java.util.Scanner;

public class FindIndexFromArray {
    public static void main(String[] args) {
        int[] arr = {11, 3, 54, 6, 7, 8};
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数字");
        int num = scanner.nextInt();
        int index = findIndex(arr, num);
        System.out.println(index);
    }

    private static int findIndex(int[] arr, int num) {
        int a = -1;
        for (int i = 0; i < arr.length; i++) {
            if (num == arr[i]) {
                a = i;
//                return a;
                break;
            }
        }
        return a;
    }
}
